/**           
 * King.java
 * Auti i class epistrefi oles tis pithanes/nomimes kinisis tou King.
 */
package gameStructure;

import java.awt.Point;
import java.util.ArrayList;
import java.util.Vector;

/**
 * 
 * @author Stordopoulos Dimitris <stordop@csd.uoc.gr>
 */
public class King extends  Piece{
    /**
     * 
     * @param pos Thesi tis King.
     * @param clr To hroma tis King.
     */
    public King(Point pos, char clr){
        p=pos;
        clor=clr;
        value="King";
        mov=false;
    }
    /**
     * @preconditions Ta c,k,cnt arhikopiounde otan kalite i move 0;
     * Epistrefi Oles tis pithanes/nomimes kinisis pou bori na kani to King
     * apo tin singekrimeni thesi ( tou Point )
     * @return Vector pou periehi tis pithanes/epitreptes kinisis tou King.
     * @param Board To Board me ta pionia pano sto Chess Board.
     */
    public Vector<Point> moves( ArrayList<ArrayList> Board){
        Vector<Point> ret= new Vector();
        for(int c=-1; c<2;c++)
            for(int k=-1; k<2;k++){
                if ( ((Piece)Board.get(p.x+c).get(p.y+k))==null || ((Piece)Board.get(p.x+c).get(p.y+k)).clor!=clor ){
                    if (ret.contains(((Piece)Board.get(p.x+c).get(p.y+k)).p)) ret.addElement(((Piece)Board.get(p.x+c).get(p.y+k)).p);
                }
            }
        return ret;
    }
}